package com.swsc.ai.utils;

import org.springframework.beans.BeanUtils;

/**
 * @describe: bean转换工具
 * @author: 容若
 * @created: 2024-06-20 11:19
 */
public class BeanUtil {
    public static <T> T beanToBean(Object source, Class<T> clazz) {
        try {
            T t = clazz.newInstance();
            BeanUtils.copyProperties(source, t);
            return t;
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
        throw new RuntimeException("bean转换异常");
    }
}
